<template>
  <div class="zongy">
    <div class="to">
      <img :src="id.socoimage" alt="" />
      <h2 class="yyd">{{ id.nosocomium }}</h2>
      <div class="ta">
        <van-tag plain type="primary">{{ id.socostate }}</van-tag>
        <van-tag plain type="primary">{{ id.socolv }}</van-tag>
        <van-tag plain type="primary">综合</van-tag>
      </div>
      <div class="ga">
        <p>医院概括:</p>
        <van-text-ellipsis rows="1.5" :content="id.socodescword" />
        <button class="chak" @click="showPopup">查看简介〉</button>
        <!-- 底部弹出 -->
        <van-popup
          v-model:show="show"
          position="bottom"
          :style="{ padding: '.2rem' }"
        >
          <h2
            style="
              text-align: center;
              background: linear-gradient(
                rgb(202, 248, 202),
                rgb(234, 238, 231)
              );
            "
          >
            医院概况
          </h2>
          <h3 style="border-left: 3px solid #0ceba4">医院简介</h3>
          {{ id.socodescword }}
        </van-popup>
      </div>
    </div>
    <div class="cen">
      <p>{{ id.sococity }}</p>
      <button>去挂号</button>
    </div>

    <div class="rmy">
      <div class="rm">
        <h2>热门医生</h2>
      </div>

      <div class="yishe" v-for="(item, index) in listys" :key="index">
        <van-card
          :desc="item.doctorstate"
          :title="item.doctorname"
          :thumb="item.doctorimage"
        >
          <template #num>
            <button class="gua">去挂号</button>
          </template>
          <template #tags>
            <van-tag plain type="primary">{{ item.doctoradministre }}</van-tag>
            <van-tag plain type="primary">{{ id.nosocomium }}</van-tag>
          </template>
          <template #bottom>
            <div class="aaa">
              <p class="shan">擅长：</p>
              <van-text-ellipsis
                rows="1"
                :content="item.doctordescword"
                expand-text="展开"
                collapse-text="收起"
              />
            </div>
          </template>
        </van-card>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'

// 获取路由参数
import { useRoute, useRouter } from 'vue-router'

// 引入axios，并获取数据
import axios from 'axios'
const show = ref(false)
interface User {
  doctorstate:string;
  doctorname:string;
  doctorimage: any;
  doctoradministre: string;
  doctordescword: string;
}


// 点击查看简介按钮，弹出弹出层
const showPopup = () => {
  show.value = true
}
const route = useRoute()
const id = route.query
console.log(id)
const listys = ref<User>()

// 获取医院数据并渲染到页面上
onMounted(async () => {
  await axios
    .get('/api/hospital', {
      params: {
        pageCode: 1,
        pageSize: 10,
      },
    })
    .then(res => {
      console.log(res)
      listys.value = res.data.data.slice(0, 3)
    })
})
const router = useRouter()

</script>

<style lang="scss">
.zongy {
  width: 100%;
  height: 100%;
  padding-top: 1.3rem;
  margin: 0;
  background: linear-gradient(
    rgb(216, 247, 216),
    rgb(234, 238, 231),
    rgb(234, 238, 231),
    rgb(234, 238, 231)
  );
}
.to {
  width: 92%;
  height: 3rem;
  background-color: #fff;
  margin-left: 2.5%;
  border-radius: 0.1rem;
  padding-left: 0.2rem;
  img {
    width: 1.8rem;
    height: 1.8rem;
    background-color: #d6e3f8;
    margin-right: 0.5rem;
    margin-top: -1.4rem;
    border-radius: 0.2rem;
  }
  .yyd {
    height: .6rem;
    font-size: 0.5rem;
    margin-top: -0.3rem;
  }
  .ta {
    margin-top: -1rem;
    .van-tag {
      margin-left: 0.2rem;
    }
  }
  .ga {
    font-size: 0.3rem;
    color: rgb(88, 86, 86);
    p {
      float: left;
    }
  }
  .van-text-ellipsis {
    width: 5.6rem;
    float: left;
  }
  .chak {
    float: right;
    margin-top: -0.5rem;
    border: none;
    color: hsl(93, 68%, 28%);
    background-color: #fff;
  }
}
.cen {
  width: 92%;
  height: 2.5rem;
  background-color: #fff;
  margin-left: 4%;
  border-radius: 0.1rem;
  p {
    font-size: 0.4rem;
    padding: 0.3rem;
    color: rgb(121, 119, 119);
    margin-bottom: 0;
  }
  button {
    font-size: 0.5rem; 
    width: 90%;
    margin-left: 5%;
    background-color: #00be8c;
    border: none;
    border-radius: 0.4rem;
    color: #fff;
  }
}
.rmy {
  width: 90%;
  margin-left: 5%;
  border-radius: 0.2rem;
  height: 8.1rem;
  background-color: #fff;
  font-size: 0.3rem;
  margin-top: 0.3rem;
  .rm {
    width: 100%;
    height: 1.3rem;
    line-height: 1.3rem;
  }
  h2 {
    font-size: 0.4rem;
    width: 5.5rem;
    float: left;
    height: 100%;
    margin: 0;
    padding-left: 0.2rem;
  }
  .van-card {
    margin-top: 0.02rem;
    border-bottom: 1px solid #ccc;
  }
  p {
    color: #333;
  }
}
.gua {
  border-radius: 0.5rem;
  background-color: #4cceae;
  color: #fff;
  border: none;
  padding-left: 0.15rem;
  padding-right: 0.15rem;
}
.yishe {

  .shan {
    float: left;
  }
  .van-card {
    margin-top: 0.01rem;
    border-radius: 0.3rem;
    overflow: hidden;
  }
  .aaa {
    width: 4rem;
    height: 0.8rem;
  }
}
</style>
